//
//  StickerVCtler.m
//  CropImg
//
//  Created by lipeng on 16/3/7.
//  Copyright © 2016年 lipeng. All rights reserved.
//

#import "StickerVCtler.h"
#import "CMPasterCenterView.h"

@interface StickerVCtler ()
{
    CMPasterCenterView *pCenter;
}

@end

@implementation StickerVCtler

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor blueColor];
    
    pCenter = [[CMPasterCenterView alloc]initWithFrame:CGRectMake(0, 20, 320, 300)];
    pCenter.originImage = [UIImage imageNamed:@"main_bg"];
    pCenter.layer.borderWidth = 1;
    pCenter.layer.borderColor = [UIColor yellowColor].CGColor;
    
    [self.view addSubview:pCenter];
    
    [pCenter addPasterWithImg:[UIImage imageNamed:@"1"]];
    [pCenter addPasterWithImg:[UIImage imageNamed:@"2"]];
    
    
    UIButton *btnEditer = UIButton.new;
    [btnEditer setTitle:@"Add Pasters" forState:UIControlStateNormal];
    btnEditer.backgroundColor = [UIColor blackColor];
    [self.view addSubview:btnEditer];
    
    UIButton *btnBack = UIButton.new;
    [btnBack setTitle:@"Back View" forState:UIControlStateNormal];
    btnBack.backgroundColor = [UIColor blackColor];
    [self.view addSubview:btnBack];
    
    [btnEditer addTarget:self
                  action:@selector(btnEditer_Event:)
        forControlEvents:UIControlEventTouchUpInside];
    
    [btnBack addTarget:self
                action:@selector(btnBack_Event:)
      forControlEvents:UIControlEventTouchUpInside];
    
    
    [btnEditer mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(pCenter.bottom).offset(20);
        make.centerX.mas_equalTo(0);
        make.size.mas_equalTo(CGSizeMake(120, 40));
    }];
    
    [btnBack mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(btnEditer.bottom).offset(20);
        make.centerX.mas_equalTo(0);
        make.size.mas_equalTo(CGSizeMake(120, 40));
    }];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


-(void)btnEditer_Event:(id)sender
{
    UIImage *img = [pCenter doneEdit];
    
    pCenter.originImage = img;
}

-(void)btnBack_Event:(id)sender
{
    [self.navigationController popViewControllerAnimated:YES];
}

@end
